package unit03.day03;

import java.util.ArrayList;
import java.util.Collection;

import unit03.day02.ObjectDemo1;

/**
 * 判断当前集合是否包含给定元素
 * boolean contains(E e)
 * */
public class CollectionDemo2 {

	public static void main(String[] args) {
		Collection collection = new ArrayList();
		collection.add(new ObjectDemo1(1,2));
		collection.add(new ObjectDemo1(2,3));
		collection.add(new ObjectDemo1(3,4));
		
		ObjectDemo1 ob = new ObjectDemo1(1,2);
		boolean contains = collection.contains(ob);
		//因为重写了equals，所以表示true
		System.out.println(contains);
	}

}
